﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WJP.Events.Bus.Handlers;

namespace WJP.Events.Bus.Factories
{
    /// <summary>
    /// 这个<see cref="IEventHandlerFactory"/>实现用于处理单个实例对象的事件。
    /// </summary>
    internal class SingleInstanceHandlerFactory : IEventHandlerFactory
    {
        /// <summary>
        /// 事件处理器的实例
        /// </summary>
        public IEventHandler HandlerInstance { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="handler"></param>
        public SingleInstanceHandlerFactory(IEventHandler handler)
        {
            HandlerInstance = handler;
        }

        public IEventHandler GetHandler()
        {
            return HandlerInstance;
        }

        public Type GetHandlerType()
        {
            return HandlerInstance.GetType();
        }

        public void ReleaseHandler(IEventHandler handler)
        {

        }
    }
}
